// viewModel/SplashViewModel.kt
package com.example.bilibili_fake.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.bilibili_fake.data.model.SplashItem
import com.example.bilibili_fake.data.repository.SplashRepository
import com.example.bilibili_fake.utils.LogUtil
import kotlinx.coroutines.launch

class SplashViewModel : ViewModel() {
    private val repository = SplashRepository()
    var splashImageUrls: List<String> = emptyList()

    init {
        loadSplashImages()
    }

    fun loadSplashImages() {
        viewModelScope.launch {

            splashImageUrls = listOf("https://i0.hdslb.com/bfs/archive/1d40e975b09d5c87b11b3ae0c9ce6c6b82f63d9e.png")
            /*val result = repository.fetchSplashImages()
            result.onSuccess { images ->
                splashImageUrls = images.map { it.logoUrl }
            }.onFailure { e ->
                // 处理失败情况，例如使用默认图片
                LogUtil.e("SplashViewModel", "加载失败 ： ${e.message}")
                splashImageUrls = listOf("http://i0.hdslb.com/bfs/archive/1d40e975b09d5c87b11b3ae0c9ce6c6b82f63d9e.png")
            }*/
        }
    }
}
